from ConfigParser import SafeConfigParser

class cfg:
    
    def __init__(self, conffile):
        self.conffile = conffile
        self.confdump = SafeConfigParser()

    def get(self, section, param):
        self.confdump.read(self.conffile)
        try:
            return self.confdump.get(section, param)
        except:
            return ""

    def getint(self, section, param):
        self.confdump.read(self.conffile)
        try:
            return self.confdump.getint(section, param)
        except:
            return ""
            
    def set(self, section, param, value):
        self.confdump.set(section, param, value)
        self.confdump.write(self.conffile)
    
    def has_section(self, sectionname):
        self.confdump.read(self.conffile)
        return self.confdump.has_section(sectionname)

    def add_section(self, sectionname):
        self.confdump.add_section(sectionname)
        self.confdump.write(self.conffile)
        
conf = cfg('')
